package com.zhonghui.wms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.response.BaseResult;
import com.zhonghui.wms.domain.vo.WmsInventoryDetailsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.domain.AjaxResult;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.wms.domain.WmsInventoryDetails;
import com.zhonghui.wms.service.IWmsInventoryDetailsService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 智能仓储WMS-库存明细Controller
 *
 * @author zhonghui
 * @date 2022-05-27
 */
@Api(tags="智能仓储WMS-库存明细")
@RestController
@RequestMapping("/wms/inventoryDetails")
public class WmsInventoryDetailsController extends BaseController
{
    @Autowired
    private IWmsInventoryDetailsService wmsInventoryDetailsService;

    /**
     * 查询库存明细列表
     */
    @GetMapping("/list")
    @ApiOperation("智能仓储WMS-查询库存明细列表")
    public TableDataInfo<List<WmsInventoryDetailsVo>> list(WmsInventoryDetailsVo wmsInventoryDetailsVo)
    {
        startPage();
        List<WmsInventoryDetailsVo> list = wmsInventoryDetailsService.selectWmsInventoryDetailsList(wmsInventoryDetailsVo);
        return getDataTable(list);
    }

    /**
     * 导出库存明细列表
     */
    @Log(title = "库存明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsInventoryDetailsVo wmsInventoryDetailsVo)
    {
        List<WmsInventoryDetailsVo> list = wmsInventoryDetailsService.selectWmsInventoryDetailsList(wmsInventoryDetailsVo);
        ExcelUtil<WmsInventoryDetailsVo> util = new ExcelUtil<WmsInventoryDetailsVo>(WmsInventoryDetailsVo.class);
        util.exportExcel(response, list, "库存明细数据");
    }

    /**
     * 获取库存明细详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("智能仓储WMS-获取库存明细详细信息")
    public BaseResult<WmsInventoryDetails> getInfo(@PathVariable("id") Long id)
    {
        return BaseResult.success(wmsInventoryDetailsService.selectWmsInventoryDetailsById(id));
    }

    /**
     * 新增库存明细
     */
    @Log(title = "库存明细", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("智能仓储WMS-新增库存明细")
    public BaseResult<Integer> add(@RequestBody WmsInventoryDetailsVo wmsInventoryDetailsVo)
    {
        return BaseResult.success(wmsInventoryDetailsService.insertWmsInventoryDetails(wmsInventoryDetailsVo));
    }

    /**
     * 修改库存明细
     */
    @Log(title = "库存明细", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("智能仓储WMS-修改库存明细")
    public BaseResult<Integer> edit(@RequestBody WmsInventoryDetailsVo wmsInventoryDetailsVo)
    {
        return BaseResult.success(wmsInventoryDetailsService.updateWmsInventoryDetails(wmsInventoryDetailsVo));
    }

    /**
     * 删除库存明细
     */
    @Log(title = "库存明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("智能仓储WMS-删除库存明细")
    public BaseResult<Integer> remove(@PathVariable Long[] ids)
    {
        return BaseResult.success(wmsInventoryDetailsService.deleteWmsInventoryDetailsByIds(ids));
    }
}
